﻿using OnlineOrder.Entity;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OnlineOrder.UI.用户窗体
{
    public partial class PersonalInformation : Form
    {
        public PersonalInformation()
        {
            InitializeComponent();
        }
        string loginUserName = LoginForm.LoginUserName;
        private void PersonalInformation_Load(object sender, EventArgs e)
        {
            
            string sql = $"select username,name,sex,tele,place from [User] where username='"+loginUserName+"'";
            DataTable dataTable = Utils.SqlHelper.ExecuteDataTable(sql);
            UserNameBox.Text = dataTable.Rows[0]["username"].ToString();
            NameBox.Text = dataTable.Rows[0]["name"].ToString();
            SexBox.Text = dataTable.Rows[0]["sex"].ToString();
            PhoneBox.Text = dataTable.Rows[0]["tele"].ToString();
            PalceBox.Text = dataTable.Rows[0]["place"].ToString();
        }

        private void save_Click(object sender, EventArgs e)
        {
            string sql = $"update [User] set name='"+ NameBox.Text + "',username='"+ UserNameBox.Text + "',sex='"+ SexBox.Text + "',tele='"+ PhoneBox.Text + "',place='"+ PalceBox.Text + "'";
            Utils.SqlHelper.ExecuteNonQuery(sql);
            this.Close();
        }
    }
}
